package com.jia.blog.controller;


import com.jia.blog.common.lang.R;
import com.jia.blog.entity.Link;
import com.jia.blog.service.LinkService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jiajia
 * @since 2020-12-02
 */
@RestController
@RequestMapping("/link")
@Api(tags = "相关链接管理")
public class LinkController {

    @Autowired
    LinkService linkService;

    @GetMapping("/list")
    public R list() {
        List<Link> list = linkService.list();
        return R.ok().data("data",list);
    }
    @PostMapping("/save")
    public R save(@RequestBody Link link) {
        linkService.save(link);
        return R.ok();
    }
    @PutMapping("/update")
    public R update(@RequestBody Link link){
        linkService.updateById(link);
        return R.ok();
    }
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable("id") Long id) {
        linkService.removeById(id);
        return R.ok();
    }


}
